<!-- 
    Copyright (C)  2011  chen wei hua.
    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 2.0
    or any later version published by the Free Software Foundation;
    with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
    A copy of the license is included in the section entitled "GNU Free Documentation License".
 -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>基础数据管理-物料管理</title>
<%@ include file="../common/config.jsp"%>
<%@ include file="../common/pageable.jsp"%>
<script type="text/javascript" src="js/jquery/chinaArea/jquery.fillOptions.js"></script>
<script type="text/javascript">
function deleteItem(id){
	if (window.confirm('确定要删除这个物料吗?')==true) {
		window.location.href = 'deleteMaterials.action?materialsId=' + id;
	}
}
    /**
     * Callback function that displays the content.
     *
     * Gets called every time the user clicks on a pagination link.
     *
     * @param {int} page_index New Page index
     * @param {jQuery} jq the container with the pagination links as a jQuery object
     */
    function pageselectCallback(page_index, jq){
    	var oldPageIndex = $("#pageInfo_pageIndex").val();
        if (page_index != oldPageIndex) {
        	$("#pageInfo_pageIndex").val(page_index);
        	$("#materialsList").submit();
        }
        return false;
    }

    function querySubmit() {
    	 $("#pageInfo_pageIndex").val("0");
    	 $("#materialsList").submit();
    	 return false;
    }
    
 	$(document).ready(function() {
 		$("#root_category").bind("change", function() {
			var parentId = $(this).val();
			$("#child_category").fillOptions(
					"queryMaterialsCategoryJOSN.action?categoryId=" + parentId,
					{datatype:"json",text:"name",value:"id",jsonData:"categoryList"});
		});
	});
</script>
</head>
<body>
    <div class="subnav" align="left">
           <table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="100%" align="left" height="31">&nbsp;<img src="images/title-pk.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt1">基础数据管理</span>
			&nbsp;<img src="images/leftico2.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt2">物料管理</span></td>
		  </tr>
		</table>
      </div>
<s:actionerror cssStyle="color:red"/>
<table width="99%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="right"><input type="button" value="添加物料" onclick='javascript:window.location.href="addMaterials.action"'  class="input1" /></td>
  </tr>
</table>
<div class="main_1">
  <table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D3DEEF">
    <tr align="left">
      <td bgcolor="#FFFFFF">
        <s:form action="materialsList" name="condition" theme="simple">
      	<s:hidden id="pageInfo_pageIndex" name="pageInfo.pageIndex" />
      	<table width="100%" border="0" cellspacing="1" cellpadding="2">
        <tr>
          <td width="10%" align="right">分类</td>
          <td width="30%">
          	<s:select id="root_category"
          		list="categoryList"
          		listKey="id"
          		listValue="name"
          		headerKey="-1"
          		headerValue="-请选择-" />
         	<s:select id="child_category"
         	 	name="condition.category"
         	 	list="#{'-1':'-请选择-'}"
         	 	cssClass="{selected:true}"/>
          </td>
          <td width="10%" align="right">物料编码</td>
          <td width="10%"><s:textfield name="condition.code" size="15" /></td>
          <td width="10%" align="right">物料名称</td>
          <td width="10%"><s:textfield name="condition.name" size="30" /></td>
          <td width="30%" align="right">
            <input type="button" value="查询 " class="input1" onclick="querySubmit()" />
          </td>
        </tr>
        </table>
        </s:form>
      </td>
    </tr>
  </table>
</div>
<div class="ksglxx2">

  <table width="100%" cellpadding="0" cellspacing="1" border="0" class="ksglxx2a">
        <tr class="ksglxx2bg">
           <th width="10%" align="left">物料代码</th>
           <th width="10%" align="left">物料分类</th>
           <th width="10%" align="left">物料名称</th>
           <th width="20%" align="left">属性描述</th>
		   <th width="8%" align="left">单位</th>
           <th width="8%" align="left">安全库存数</th>
           <th width="8%" align="left">实际库存数</th>
           <th align="left"></th>
        </tr>
        <s:iterator value="materialsList" id="materials" status="st">
          <s:if test="#st.Odd">
            <tr class="odd">
              <td><s:property value="#materials.code" /></td>
              <td><s:property value="#materials.categoryName" /></td>
              <td><s:property value="#materials.name" /></td>
              <td><s:property value="#materials.property" /></td>
      		  <td><s:property value="#materials.units" /></td>
              <td><s:property value="#materials.safeNumber" /></td>
              <td><s:property value="#materials.number" /></td>
              <td align="center">
                <a class="b" href='editMaterials.action?MaterialsId=<s:property value="#materials.id" />'>
                  <img src="images/Edit.gif" alt="Edit" border="0" align="absmiddle" /></a>&nbsp;&nbsp;
                <a class="b" href='javascript:deleteItem(<s:property value="#materials.id" />)'>
                  <img src="images/Delete.gif" alt="Delete" border="0" align="absmiddle" /></a>
         	  </td>
            </tr>
          </s:if>
          <s:else>
            <tr class="even">
              <td><s:property value="#materials.code" /></td>
              <td><s:property value="#materials.categoryName" /></td>
              <td><s:property value="#materials.name" /></td>
              <td><s:property value="#materials.property" /></td>
      		  <td><s:property value="#materials.units" /></td>
              <td><s:property value="#materials.safeNumber" /></td>
              <td><s:property value="#materials.number" /></td>
              <td align="center">
                <a class="b" href='editMaterials.action?MaterialsId=<s:property value="#materials.id" />'>
                  <img src="images/Edit.gif" alt="Edit" border="0" align="absmiddle" /></a>&nbsp;&nbsp;
                <a class="b" href='javascript:deleteItem(<s:property value="#materials.id" />)'>
                  <img src="images/Delete.gif" alt="Delete" border="0" align="absmiddle" /></a>
         	  </td>
            </tr>
           </s:else>
         </s:iterator>
        </table>
		
		<!--分页开始-->
		<div style="float:right;">
			<br style="clear:both;" /> 
			<div id="Pagination"></div> 
		</div>
		<!--分页结束-->

</div>
</body>
</html>
